package com.sip.stream.utils.zfy;

import android.os.Environment;
import android.os.StatFs;
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.util.Log;
import com.sip.stream.utils.zfy.status.ZFYStatus;
import java.io.File;
import java.lang.reflect.Method;
import java.util.Iterator;

public class ZFYFilePath {
    public static final String AI_CACHE = "AI_CACHE";
    public static final String AUDIO_NOTE = "AUDIO_NOTE";
    public static final String CACHE = "CACHE";
    public static final String DB = "DB";
    public static final String DEBUGLOG = "DEBUGLOG";
    public static final String DOWNLOAD = "DOWNLOAD";
    public static float FULL_SIZE = 4.0f;
    public static final String FUN_DIR = "gosuncn";
    public static final String LICENSE = "license";
    public static final String LOCATION = "LOCATION";
    public static final String MEDIA_AUDIO = "MEDIA_AUDIO";
    public static final String MEDIA_PHOTO = "MEDIA_PHOTO";
    public static final String MEDIA_VIDEO = "MEDIA_VIDEO";
    public static final String MEDIA_VIDEO_PRE = "MEDIA_VIDEO_PRE";
    public static final String ROOT_PATH = "ROOT_PATH";
    private static final String TAG = "ZFYFilePath";
    public static final String TEST = "TEST";
    public static final String UPDATE = "UPDATE";
    public static final String ZFYLOG = "ZFYLOG";
    public static final String ZFYPRIVATELOG = "ZFYPRIVATELOG";
    private static String rootDir = "/storage/9016-4EF8";
    private static ZFYFilePath shareInstance;

    private ZFYFilePath() {
        checkCardStatus();
    }

    public static ZFYFilePath getInstance() {
        if (shareInstance == null) {
            synchronized (ZFYFilePath.class) {
                shareInstance = new ZFYFilePath();
            }
        }
        return shareInstance;
    }

    public String getAbsoluteFileDir(String str) {
        String str2;
        str.hashCode();
        char c = 65535;
        switch (str.hashCode()) {
            case -2084521848:
                if (str.equals(DOWNLOAD)) {
                    c = 0;
                    break;
                }
                break;
            case -1785516855:
                if (str.equals(UPDATE)) {
                    c = 1;
                    break;
                }
                break;
            case -1650970281:
                if (str.equals(ZFYLOG)) {
                    c = 2;
                    break;
                }
                break;
            case -1611296843:
                if (str.equals("LOCATION")) {
                    c = 3;
                    break;
                }
                break;
            case -1236952197:
                if (str.equals(MEDIA_AUDIO)) {
                    c = 4;
                    break;
                }
                break;
            case -1223475753:
                if (str.equals(MEDIA_PHOTO)) {
                    c = 5;
                    break;
                }
                break;
            case -1217915872:
                if (str.equals(MEDIA_VIDEO)) {
                    c = 6;
                    break;
                }
                break;
            case -550671900:
                if (str.equals(MEDIA_VIDEO_PRE)) {
                    c = 7;
                    break;
                }
                break;
            case 2174:
                if (str.equals(DB)) {
                    c = '\b';
                    break;
                }
                break;
            case 2571410:
                if (str.equals(TEST)) {
                    c = '\t';
                    break;
                }
                break;
            case 63879010:
                if (str.equals(CACHE)) {
                    c = '\n';
                    break;
                }
                break;
            case 166757441:
                if (str.equals(LICENSE)) {
                    c = 11;
                    break;
                }
                break;
            case 465462411:
                if (str.equals(AI_CACHE)) {
                    c = '\f';
                    break;
                }
                break;
            case 1330444305:
                if (str.equals(DEBUGLOG)) {
                    c = '\r';
                    break;
                }
                break;
            case 1698528590:
                if (str.equals(ZFYPRIVATELOG)) {
                    c = 14;
                    break;
                }
                break;
            case 1949030754:
                if (str.equals(ROOT_PATH)) {
                    c = 15;
                    break;
                }
                break;
            case 2063834843:
                if (str.equals(AUDIO_NOTE)) {
                    c = 16;
                    break;
                }
                break;
        }
        switch (c) {
            case 0:
                str2 = rootDir + File.separator + "download" + File.separator;
                break;
            case 1:
                str2 = rootDir + File.separator + "update" + File.separator;
                break;
            case 2:
                str2 = rootDir + File.separator + "log" + File.separator;
                break;
            case 3:
                str2 = getMediaRootPath() + File.separator + ZFYUserInfo.defaultUserInfo().getUserCode() + File.separator + "LocationData" + File.separator;
                break;
            case 4:
            case 5:
            case 6:
                str2 = getMediaRootPath() + File.separator + ZFYUserInfo.defaultUserInfo().getUserCode() + File.separator;
                break;
            case 7:
                str2 = getMediaRootPath() + File.separator + "prerecoding" + File.separator;
                break;
            case '\b':
                str2 = rootDir + File.separator + FUN_DIR + File.separator + "db" + File.separator;
                break;
            case '\t':
                str2 = rootDir + File.separator + "test" + File.separator;
                break;
            case '\n':
                str2 = rootDir + File.separator + "cache" + File.separator;
                break;
            case 11:
                str2 = rootDir + File.separator + FUN_DIR + File.separator + LICENSE + File.separator;
                break;
            case '\f':
                str2 = rootDir + File.separator + "cache" + File.separator + "ai" + File.separator;
                break;
            case '\r':
                str2 = rootDir + File.separator + "log" + File.separator;
                break;
            case 14:
                str2 = rootDir + "log" + File.separator + ZFYUserInfo.defaultUserInfo().getUserCode() + File.separator;
                break;
            case 15:
                return rootDir;
            case 16:
                str2 = rootDir + File.separator + FUN_DIR + File.separator + "audionote" + File.separator;
                break;
            default:
                return null;
        }
        File file = new File(str2);
        if (file.exists() || file.mkdirs()) {
            return str2;
        }
        Log.e(TAG, "mkdirs failed " + str2);
        return null;
    }

    public static String getMediaRootPath() {
        return rootDir + File.separator + "DCIM";
    }

    public static String getPreRecordingCacheDirPath() {
        String str = rootDir + File.separator + FUN_DIR + File.separator + "prerecoding" + File.separator;
        File file = new File(str);
        if (file.exists() || file.mkdirs()) {
            return str;
        }
        return null;
    }

    public static String getFormatCacheDirPath() {
        String str = rootDir + File.separator + FUN_DIR + File.separator + "format" + File.separator;
        File file = new File(str);
        if (file.exists() || file.mkdirs()) {
            return str;
        }
        return null;
    }

    public static String getBarstreamBackupPath() {
        String str = rootDir + File.separator + FUN_DIR + File.separator + "backup" + File.separator;
        File file = new File(str);
        if (file.exists() || file.mkdirs()) {
            return str;
        }
        return null;
    }

    public static String getDeviceInfoTxtPath() {
        getInstance().checkCardStatus();
        return rootDir + File.separator + "ID.txt";
    }

    public static String getDeviceJCSCmdPath() {
        getInstance().checkCardStatus();
        return rootDir + File.separator + FUN_DIR + "/jcs/dsjcmd.json";
    }

    public static String getJCSDeviceInfoTxtPath() {
        getInstance().checkCardStatus();
        return rootDir + File.separator + "regfile.ini";
    }

    public synchronized boolean checkCardStatus() {
        return true;
    }

    public String getRootDir() {
        return rootDir;
    }

    public long getEmptySize() {
        try {
            StatFs statFs = new StatFs(rootDir);
            return statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong();
        } catch (Exception unused) {
            return 0L;
        }
    }

    public String getEmptyMB() {
        try {
            StatFs statFs = new StatFs(rootDir);
            return String.format("%.2f", Float.valueOf(((float) (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong())) / 1048576.0f));
        } catch (Exception unused) {
            return "-1";
        }
    }

    public String getEmptyGB() {
        try {
            StatFs statFs = new StatFs(rootDir);
            float availableBlocksLong = ((float) (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong())) / 1.07374182E9f;
            ZFYStatus.getInstance().setEmptyGbSize(availableBlocksLong);
            return String.format("%.2f", Float.valueOf(availableBlocksLong));
        } catch (Exception unused) {
            return "-1";
        }
    }

    public String getTotalGB() {
        try {
            StatFs statFs = new StatFs(rootDir);
            return String.format("%.2f", Float.valueOf(((float) (statFs.getBlockCountLong() * statFs.getBlockSizeLong())) / 1.07374182E9f));
        } catch (Exception unused) {
            return "-1";
        }
    }

    public String getTotalGB_t() {
        try {
            StatFs statFs = new StatFs(rootDir);
            return String.format("%.2f", Float.valueOf(((float) (statFs.getBlockCountLong() * statFs.getBlockSizeLong())) / 1.0E9f));
        } catch (Exception unused) {
            return "-1";
        }
    }

    public float getEmptyGBFloat() {
        try {
            StatFs statFs = new StatFs(rootDir);
            return ((float) (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong())) / 1.07374182E9f;
        } catch (Exception unused) {
            return 0.0f;
        }
    }

    public boolean isStorageFull() {
        try {
            StatFs statFs = new StatFs(rootDir);
            float availableBlocksLong = ((float) (statFs.getAvailableBlocksLong() * statFs.getBlockSizeLong())) / 1.07374182E9f;
            ZFYStatus.getInstance().setEmptyGbSize(availableBlocksLong);
            Log.i(TAG, "checkDeviceStatus " + availableBlocksLong + " FULL_SIZE " + FULL_SIZE);
            return availableBlocksLong <= FULL_SIZE;
        } catch (Exception e) {
            e.printStackTrace();
            return true;
        }
    }
}
